package csu.web.mypetstore.web.servlet;

import csu.web.mypetstore.domain.Account;
import csu.web.mypetstore.persistence.AccountDao;
import csu.web.mypetstore.persistence.DBUtil;
import csu.web.mypetstore.persistence.impl.AccountDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.Connection;

public class MyAccountServlet extends HttpServlet {

    private static final String ACCOUNT_FORM="/WEB-INF/jsp/account/IncludeAccountFields.jsp";
    private static final String NULL_FORM="/WEB-INF/jsp/common/accountnull.jsp";


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        Account account = (Account) session.getAttribute("loginAccount");


        String firstName = req.getParameter("firstName");
        String lastName = req.getParameter("lastName");
        String email = req.getParameter("email");
        String phone = req.getParameter("phone");
        String address1 = req.getParameter("address1");
        String city = req.getParameter("city");
        String address2 = req.getParameter("address2");
        String state = req.getParameter("state");
        String zip = req.getParameter("zip");
        String country = req.getParameter("country");

        if(account==null){
            req.getRequestDispatcher(NULL_FORM).forward(req, resp);
        }else{
            req.getRequestDispatcher(ACCOUNT_FORM).forward(req, resp);
        }
    }
}
